package cn.edu.ldu.communityqa.communityqa.service;

import cn.edu.ldu.communityqa.communityqa.dao.UserDao;
import cn.edu.ldu.communityqa.communityqa.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SessionService {
    public final UserDao userService;

    @Autowired
    public SessionService(UserDao userService) {
        this.userService = userService;
    }

    public boolean isValidSession(String name, String password) {

        User user = userService.findByUsernameAndPassword(name, password);
        if (user == null) {
            return false;
        }
        return true;
    }
}
